<template>
  <s-layout title="门店" tabbar="/pages/index/store">
    <view class="container">
      <!-- 筛选栏 -->
      <view class="filter-bar">
        <text class="filter-item">全部</text>
        <text class="filter-item">距离最近 ▼</text>
      </view>

      <!-- 卡片列表（循环渲染核心） -->
      <view class="card-list">
        <!-- 用 v-for 循环渲染每个卡片 -->
        <view class="shop-card" v-for="(shop, index) in shopList" :key="index">
          <!-- 店铺标题区 -->
          <view class="shop-title">
            <text class="main-title">非野集</text>
            <view class="stamp">非野集</view>
          </view>

          <!-- 店铺信息区 -->
          <view class="shop-info">
            <text class="shop-name">{{ shop.title }}</text>
            <view class="address-row">
              <text class="address">{{ shop.address }}</text>
              <text class="distance">{{ shop.distance }}</text>
            </view>
            <text class="business-hours">营业时间：{{ shop.businessHours }}</text>
          </view>

          <!-- 操作按钮区 -->
          <view class="action-btns">
            <button class="btn call-btn" @click="callShop(shop.phone)">
              拨打门店电话
            </button>
            <button class="btn wechat-btn" @click="openWechat(shop.wechat)">
              微信联系门店
            </button>
          </view>
        </view>
      </view>
    </view>
  </s-layout>
</template>

<script>
export default {
  data() {
    return {
      // 模拟店铺数据（实际项目可从接口获取）
      shopList: [
        {
          title: "非野集 - 商丘店",
          address: "河南省商丘市睢阳区碧桂园天悦府二期西门",
          distance: "898m",
          businessHours: "10:00-22:00",
          phone: "13800138000",
          wechat: "feiyeji001"
        },
        {
          title: "非野集 - 郑州店",
          address: "河南省郑州市金水区花园路39号",
          distance: "1.2km",
          businessHours: "09:30-21:30",
          phone: "13900139000",
          wechat: "feiyeji002"
        },
        {
          title: "非野集 - 洛阳店",
          address: "河南省洛阳市涧西区南昌路1号",
          distance: "2.5km",
          businessHours: "10:00-22:30",
          phone: "13700137000",
          wechat: "feiyeji003"
        }
      ]
    };
  },
  methods: {
    // 拨打门店电话（调用 UniApp 原生API）
    callShop(phone) {
      uni.makePhoneCall({
        phoneNumber: phone,
        fail: (err) => {
          console.log("拨打电话失败：", err);
        }
      });
    },
    // 微信联系（实际项目可跳转小程序或打开客服）
    openWechat(wechat) {
      uni.showToast({
        title: `即将打开微信联系：${wechat}`,
        icon: "none"
      });
    }
  }
};
</script>

<style scoped>
/* 基础容器样式 */
.container {
  min-height: 100vh;
  background-color: rgba(0, 0, 0, 0.05);
}

/* 导航栏样式 */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 44px;
  background-color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid #eee;
  z-index: 999;
}

.nav-title {
  font-size: 18px;
  font-weight: bold;
}

/* 筛选栏样式 */
.filter-bar {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  background-color: #fff;
}

.filter-item {
  font-size: 14px;
  color: #333;
}

/* 卡片列表容器 */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 单个卡片样式 */
.shop-card {
  background-color: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* 标题区样式 */
.shop-title {
  background-color: #f9f9f9;
  padding: 16px;
  position: relative;
}

.main-title {
  font-size: 22px;
  font-weight: bold;
  color: #333;
}

.stamp {
  position: absolute;
  top: 18px;
  left: 100px;
  font-size: 12px;
  color: #fff;
  background-color: #e53e3e;
  padding: 2px 8px;
  border-radius: 2px;
  transform: rotate(-15deg);
}

/* 信息区样式 */
.shop-info {
  padding: 16px;
  border-bottom: 1px solid #f1f1f1;
}

.shop-name {
  font-size: 16px;
  font-weight: 500;
  color: #333;
  display: block;
  margin-bottom: 8px;
}

.address-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.address {
  font-size: 14px;
  color: #666;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.distance {
  font-size: 14px;
  color: #e53e3e;
  margin-left: 8px;
}

.business-hours {
  font-size: 14px;
  color: #999;
}

/* 按钮区样式 */
.action-btns {
  display: flex;
}

.btn {
  flex: 1;
  height: 44px;
  line-height: 44px;
  background-color: #f5f5f5;
  border: none;
  font-size: 14px;
  color: #333;
}

.btn::after {
  border: none;
  /* 清除 UniApp 按钮默认边框 */
}

.call-btn {
  border-right: 1px solid #eee;
}

.btn:active {
  background-color: #eaeaea;
}
</style>